from django.db import models

class SysMenu(models.Model):
    menu_id = models.BigAutoField(primary_key=True, verbose_name='菜单ID')
    menu_name = models.CharField(max_length=50, verbose_name='菜单名称')
    parent_id = models.BigIntegerField(default=0, verbose_name='父菜单ID')
    order_num = models.IntegerField(default=0, verbose_name='显示顺序')
    path = models.CharField(max_length=200, default='', blank=True, verbose_name='路由地址')
    component = models.CharField(max_length=255, null=True, blank=True, verbose_name='组件路径')
    query_param = models.CharField(max_length=255, null=True, blank=True, verbose_name='路由参数')
    is_frame = models.IntegerField(default=1, choices=[(0, '是'), (1, '否')], verbose_name='是否为外链')
    is_cache = models.IntegerField(default=0, choices=[(0, '缓存'), (1, '不缓存')], verbose_name='是否缓存')
    menu_type = models.CharField(max_length=1, default='', blank=True, verbose_name='菜单类型', 
                                choices=[('M', '目录'), ('C', '菜单'), ('F', '按钮')])
    visible = models.CharField(max_length=1, default='0', choices=[('0', '显示'), ('1', '隐藏')], verbose_name='显示状态')
    status = models.CharField(max_length=1, default='0', choices=[('0', '正常'), ('1', '停用')], verbose_name='菜单状态')
    perms = models.CharField(max_length=100, null=True, blank=True, verbose_name='权限标识')
    icon = models.CharField(max_length=100, default='#', blank=True, verbose_name='菜单图标')
    create_by = models.CharField(max_length=64, default='', blank=True, verbose_name='创建者')
    create_time = models.DateTimeField(auto_now_add=True, null=True, verbose_name='创建时间')
    update_by = models.CharField(max_length=64, default='', blank=True, verbose_name='更新者')
    update_time = models.DateTimeField(auto_now=True, null=True, verbose_name='更新时间')
    remark = models.CharField(max_length=500, default='', blank=True, verbose_name='备注')

    class Meta:
        db_table = 'sys_menu'
        verbose_name = '菜单权限表'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.menu_name
